package work.comeback.omo.service.imp;

import work.comeback.omo.dao.user.IUser;
import work.comeback.omo.dao.user.imp.UserImpl;
import work.comeback.omo.model.user.UserBean;
import work.comeback.omo.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    IUser userImpl = new UserImpl();

    @Override
    public UserBean findUserByID(int id) {
        return userImpl.findUserByID(id);
    }

    @Override
    public UserBean findUserByUsername(String username) {
        return userImpl.findUserByUsername(username);
    }

    @Override
    public List<UserBean> findByRole(String role) {
        return userImpl.findByRole(role);
    }

    @Override
    public void deleteUser(UserBean user) {
        userImpl.deleteUser(user);
    }

    @Override
    public void updateUser(UserBean user) {
        userImpl.updateUser(user);
    }

    @Override
    public void createUser(UserBean user) {
        userImpl.createUser(user);
    }

    @Override
    public boolean hasRecord(String uname, String pwd) {
        UserBean dbUser = this.findUserByUsername(uname);

        if (dbUser == null) {
            return false;
        }
        return dbUser.isSamePwd(pwd);
    }
}
